Skip to content

fix: enrich the create-time Spotify attach with the real profile - #796

Open
sweetmantech wants to merge 1 commit into
mainfrom
feat/enrich-create-attach-social
Open

fix: enrich the create-time Spotify attach with the real profile#796
sweetmantech wants to merge 1 commit into
mainfrom
feat/enrich-create-attach-social

Conversation

@sweetmantech

@sweetmantech sweetmantech commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Row 16 of chat#1889: a social saved by resolveOrCreateArtist's create path persisted username: "artist" (the URL path segment), followerCount: 0 and no avatar, so verify-socials rendered Spotify @artist · 0 followers for an artist with 1.8M followers. Scope was narrowed 2026-07-29: the junk metadata comes only from this create-time attach; the social-fix/re-add path already writes real metadata (proven on chat#1894's preview walk).

What it does

  • lib/artists/enrichArtistSpotifyProfile.ts (new, SRP): mint a Spotify app token → getArtist → delegate to the existing enrichSearchedArtistProfile (the same enrichment runValuationHandler uses, which already handles the normalized-profile_url upsert). Best-effort: never throws; skips cleanly when the token or profile fetch fails, leaving the social fixable in verify-socials.
  • resolveOrCreateArtist: after the create-path updateArtistSocials attach succeeds, enrich with the real handle/followers/avatar. Inside the same try block — a failed attach leaves nothing to enrich. Canonical-link path unchanged (its social already carries real metadata).

Tests (TDD, red→green)

  • 4 new tests: lib/artists/__tests__/enrichArtistSpotifyProfile.test.ts (delegates with the fetched profile; skips on token failure; skips on profile-fetch failure; never throws)
  • 3 wiring cases added to resolveOrCreateArtist.test.ts (enriches on create; not on plain create; not when the attach fails)
  • All confirmed RED before implementation
  • Full suite: 4270 tests passed; tsc --noEmit at the 236-error pre-existing baseline (none in touched files); eslint clean

Independent of the row 15 chain — no migration dependency. Tracked in chat#1889 row 16.

🤖 Generated with Claude Code


Summary by cubic

Fix incorrect Spotify social metadata on newly created artists by enriching the attach with the real profile right after creation. verify-socials now shows the real handle, follower count, and avatar.

  • Bug Fixes
    • Added enrichArtistSpotifyProfile to mint a token, fetch the Spotify artist via getArtist, and delegate to enrichSearchedArtistProfile (best-effort, never throws).
    • Updated resolveOrCreateArtist to call enrichment immediately after updateArtistSocials on the create path, only when a Spotify ID is present and the attach succeeds.

Written for commit 951782c. Summary will update on new commits.

Review in cubic

resolveOrCreateArtist's create path saved the URL path segment as the
username, so verify-socials rendered 'Spotify @artist · 0 followers'.
Fetch the real Spotify profile after the attach and reuse
enrichSearchedArtistProfile to write the real handle, follower count
and avatar. chat#1889 row 16.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
api Ready Ready Preview Jul 29, 2026 8:27pm

Request Review

@cursor

cursor Bot commented Jul 29, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@sweetmantech, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 16 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 609bbd4b-de26-4504-8c78-5a7cc8979c0d

📥 Commits

Reviewing files that changed from the base of the PR and between 3bb0ca2 and 951782c.

⛔ Files ignored due to path filters (2)
  • lib/artists/__tests__/enrichArtistSpotifyProfile.test.ts is excluded by !**/*.test.*, !**/__tests__/** and included by lib/**
  • lib/artists/__tests__/resolveOrCreateArtist.test.ts is excluded by !**/*.test.*, !**/__tests__/** and included by lib/**
📒 Files selected for processing (2)
  • lib/artists/enrichArtistSpotifyProfile.ts
  • lib/artists/resolveOrCreateArtist.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 4 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.
Architecture diagram
sequenceDiagram
    participant Caller as Caller (resolveOrCreateArtist)
    participant Resolve as resolveOrCreateArtist
    participant Social as updateArtistSocials
    participant Enrich as enrichArtistSpotifyProfile (NEW)
    participant Token as generateAccessToken
    participant Spotify as getArtist (Spotify API)
    participant EnrichProfile as enrichSearchedArtistProfile

    Note over Caller,Resolve: Create path (no canonical artist exists)
    Caller->>Resolve: resolveOrCreateArtist(params)
    Resolve->>Resolve: Create artist in DB, insert account-artist link

    alt attach succeeds (social link created)
        Resolve->>Social: updateArtistSocials(account_id, { SPOTIFY: url })
        Social-->>Resolve: success
        Note over Resolve: NEW: Enrich the just-attached social
        Resolve->>Enrich: enrichArtistSpotifyProfile({ artistId, spotifyArtistId })

        alt token minted successfully
            Enrich->>Token: generateAccessToken()
            Token-->>Enrich: { access_token: "tok", error: null }

            alt profile fetched successfully
                Enrich->>Spotify: getArtist(spotifyArtistId, token)
                Spotify-->>Enrich: { artist: realProfile }
                Enrich->>EnrichProfile: enrichSearchedArtistProfile({ artistId, spotifyArtistId, spotifyArtist })
                Note over EnrichProfile: Updates social handle/followers/avatar
                EnrichProfile-->>Enrich: void
                Enrich-->>Resolve: void (enrichment done)
            else profile fetch fails
                Spotify-->>Enrich: { artist: null, error: ... }
                Note over Enrich: NEW: Best-effort skip, leave social fixable later
                Enrich-->>Resolve: void (no enrich)
            end
        else token mint fails
            Token-->>Enrich: { access_token: null, error: ... }
            Note over Enrich: NEW: Best-effort skip
            Enrich-->>Resolve: void (no enrich)
        end
        Note over Enrich: NEW: Any exception caught inside, never throws
        Resolve-->>Caller: { artist: created, created: true }
    else attach fails (exception)
        Social-->>Resolve: (throws)
        Note over Resolve: Social attach failed – nothing to enrich, skip
        Resolve-->>Caller: (caught, returns empty result or fallback)
    end

    Note over Caller,Resolve: Canonical link path (unchanged) – not depicted
Loading

Auto-approved: Focused bug fix that corrects create-time Spotify social metadata to show real handle/followers/avatar. Bounded to the create path, best-effort, uses existing enrichment, and has thorough tests.

Re-trigger cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant